/*
 * Program.h
 *
 *  Created on: 13 mai 2011
 *      Author: seeme
 */

#ifndef PROGRAM_H_
#define PROGRAM_H_

#include <GL/glew.h>
#include <map>
#include <string>
#include "../../../../LogManager/Log.hpp"

class Program{
private:
	GLuint m_progId;
	std::map<std::string, GLuint> m_uniforms;

public:
	Program(): m_progId(0){}

	void pushAttrib(std::string attrib);
	void pushAttrib(const char* attrib);

	GLuint operator()(std::string attrib);
	GLuint operator()(const char* attrib);

	Program(const GLuint vShader, const GLuint fShader): m_uniforms(){
		GLint status;
		char errMsg[256];
		GLint len;

		m_progId = glCreateProgram();

		glAttachShader(m_progId, vShader);
		glAttachShader(m_progId, fShader);

		glLinkProgram(m_progId);
		glGetProgramiv(m_progId, GL_LINK_STATUS, &status);


		if(GL_TRUE != status){
			glGetProgramInfoLog(m_progId, 256, &len, errMsg);

			Log::e("Program") << "Can't link program: " << errMsg;
		}
	}


	const GLuint getId(){return m_progId;}


};
#endif /* PROGRAM_H_ */
